package Strategy;

import lombok.Data;

import java.math.BigDecimal;

/**
 * @author liuyang
 * @since 2022/6/24 18:08
 */
@Data
public class GetCashReturn implements Strategy {
    private BigDecimal disAmount;
    private BigDecimal maxAmount;

    public GetCashReturn(String maxAmount, String disAmount) {
        this.disAmount = new BigDecimal(disAmount);
        this.maxAmount = new BigDecimal(maxAmount);
    }

    @Override
    public String payMoney(String money) {
        BigDecimal newMoney = new BigDecimal(money);
        return newMoney.subtract(newMoney.divideToIntegralValue(maxAmount).multiply(disAmount)).toString();
    }
}
